home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 2
/
Gekikoh Dennoh Club Vol. 2 (Japan).7z
/
Gekikoh Dennoh Club Vol. 2 (Japan) (Track 01).bin
/
tools
/
cd2pcmt
/
source.lzh
/
music_bios.c
< prev
next >
Wrap
Text File
|
1997-10-01
|
5KB
|
181 lines
#include "cd2pcm.h"
#include "extern.h"
/*
低レベルルーチン (CD-ROMを直接操作するルーチン集。各々のドライブに
依存するルーチン。)
*/
/* ストップコマンドを送る */
int StpDsk( void )
{
unsigned char buf[256]; /* ローカルワーク */
memset( buf, 0x00, 10 );
buf[0] = 0x4b; /* scsi2 Pause/Resume Command */
return( scsi_cmd( 10, buf, 0, buf ) );
}
/* Resume コマンドを送る */
int Resume( void )
{
unsigned char buf[256]; /* ローカルワーク */
memset( buf, 0x00, 10 );
buf[0] = 0x4b; /* scsi2 Pause/Resume Command */
buf[8] = 0x01; /* Resume Command */
return( scsi_cmd( 10, buf, 0, buf ) );
}
/* 演奏状態を調べる */
int ChkPly( PLYINF *plyinf )
{
unsigned char buf2[256]; /* ローカルワーク */
int rc;
if ( ReadSub( buf2 ) == 0 )
{
plyinf->fg = buf2[1]; /* 状態 */
plyinf->track_no = buf2[6]; /* 曲番号 */
plyinf->time = buf2[13] * 0x10000 + buf2[14] * 0x100 + buf2[15];
plyinf->address = buf2[9] * 0x10000 + buf2[10] * 0x100 + buf2[11];
rc = 0;
#ifdef DEBUG1
printf(" Index = %d\n",buf[7]);
#endif
}
else
rc = -1;
return(rc);
}
/* 演奏させる */
int PlyDsk( int start , int stop )
{
unsigned char buf[256]; /* ローカルワーク */
int dmymin,dmymax; /* ダミー変数 */
int rc;
if ( stop == -1 )
{
/* 最後まで演奏する */
if ( RedTOC( &stop, &dmymin, &dmymax ) != 0 )
return(-1);
stop = bin2time( time2bin( stop ) -1 );
}
/* Play Audio MSF Command */
memset( buf, 0x00, 10 );
buf[0] = 0x47; /* Play Audio MSF Command */
buf[3] = ( start / 0x10000 ) & 0xff;
buf[4] = ( start / 0x100 ) & 0xff;
buf[5] = start & 0xff;
buf[6] = ( stop / 0x10000 ) & 0xff;
buf[7] = ( stop / 0x100 ) & 0xff;
buf[8] = stop & 0xff;
if ( (rc=scsi_cmd( 10, buf, 0, buf ))!=0 )
if ( (rc=scsi_cmd( 10, buf, 0, buf ))!=0 )
rc=scsi_cmd( 10, buf, 0, buf );
return( rc );
}
/* Read Sub-Channel */
int ReadSub( unsigned char *buf2 )
{
unsigned char buf[256]; /* ローカルワーク */
int rc;
/* Read Sub-Channel Command */
memset( buf, 0x00, 10 );
buf[0] = 0x42; /* Read Sub-Channel Command */
buf[1] = 0x02; /* Set MSF Bit */
buf[2] = 0x40; /* Set SubQ Bit */
buf[3] = 0x01; /* CD-ROM Current Posision */
buf[8] = 16; /* Allocation Length */
if ( (rc=scsi_cmd( 10, buf, 16, buf2 ))!=0 )
if ( (rc=scsi_cmd( 10, buf, 16, buf2 ))!=0 )
rc=scsi_cmd( 10, buf, 16, buf2 );
return( rc );
}
/* 曲数と最終演奏アドレスを求める */
int RedTOC(int *leadout_address, int *min, int *max)
{
unsigned char buf[256]; /* ローカルワーク */
unsigned char buf2[256]; /* ローカルワーク */
int rc;
/* Leadout Track Address get & Min. Max Track get */
memset( buf, 0x00, 10 );
buf[0] = 0x43; /* scsi2 ReadTOC Command */
buf[1] = 0x02; /* Set MSF Bit */
buf[6] = 0xaa; /* LeadoutOut Track */
buf[8] = 12; /* Allocation Length */
if ( scsi_cmd( 10, buf, 12, buf2 )!=0 )
if ( scsi_cmd( 10, buf, 12, buf2 )!=0 )
if ( scsi_cmd( 10, buf, 12, buf2 )!=0 )
return(-1);
*leadout_address = buf2[9] * 0x10000 + buf2[10] * 0x100 + buf2[11];
*min = buf2[2]; /* Min. Track */
*max = buf2[3]; /* Max. Track */
rc = 0;
return(rc);
}
/* 演奏アドレスを求める */
int Music_inf( int Track_no, int *start_address )
{
unsigned char buf[256]; /* ローカルワーク */
unsigned char buf2[256]; /* ローカルワーク */
int rc;
/* Start Track Address get */
memset( buf, 0x00, 10 );
buf[0] = 0x43; /* scsi2 ReadTOC Command */
buf[1] = 0x02; /* Set MSF Bit */
buf[6] = (unsigned char )Track_no; /* Set Start Track */
buf[8] = 12; /* Allocation Length */
if ( scsi_cmd( 10, buf, 12, buf2 )!=0 )
if ( scsi_cmd( 10, buf, 12, buf2 )!=0 )
if ( scsi_cmd( 10, buf, 12, buf2 )!=0 )
return(-1);
*start_address = buf2[9] * 0x10000 + buf2[10] * 0x100 + buf2[11];
/* CTRL_ADDR = buf[5]; */ /* ADR/CTL 利用方法がわからん。*/
#ifdef DEBUG1
printf(" CTL = %d\n",buf[5]);
#endif
rc = 0;
return(rc);
}
/* スピード変更コマンドを送る */
int SetSpeed( int bps )
{
unsigned char com[256]; /* ローカルワーク */
unsigned char buf[256];
int r;
memset( com, 0x00, 12 );
com[0] = 0xbb; /* MMC / Set Speed Command */
com[2] = bps/0x100;
com[3] = bps&0xFF;
com[4] = 0xFF; /* 書き込み速度 */
com[5] = 0xFF;
r=scsi_cmd( 12, com, 0, buf );
if ( r==2 ){
S_REQUEST( 22, SCSI_ID, buf ); //dummy 発行
com[0] = 0xbb; /* MMC / Set Speed Command */
com[4] = 0x00; /* 書き込み速度 */
com[5] = 0x00;
r=scsi_cmd( 12, com, 0, buf );
}
return r;
}